fix(daemon): skip Bun virtual entry path in detached child spawn#112
Open
dedene wants to merge 1 commit intosteipete:mainfrom
Open
fix(daemon): skip Bun virtual entry path in detached child spawn#112dedene wants to merge 1 commit intosteipete:mainfrom
dedene wants to merge 1 commit intosteipete:mainfrom
Conversation
In Bun compiled binaries, process.argv[1] is a virtual /$bunfs/... path that Bun auto-injects into every spawned child process. The daemon launcher was including this path explicitly in the spawn args, causing it to appear twice in the child's argv. The child then parsed the duplicate path as the CLI command instead of "daemon", silently failing to start. Detect the /$bunfs/ prefix and omit the entry from spawn args, letting Bun handle it automatically.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
mcporter daemon startfails with "Failed to start daemon before timeout expired" when running from a Bun compiled binary (Homebrew install). The--foregroundmode works fine.The daemon launcher uses
process.argv[1]as the CLI entry script when spawning the detached child process. In Node.js this is the script path, but in Bun compiled binaries it's a virtual/$bunfs/root/...path that Bun auto-injects into every spawned child. Including it explicitly duplicates it in the child's argv:process.argv.slice(2)then parses the duplicate path as the CLI command instead ofdaemon, so the child silently fails to start.This also affects
mcporter listandmcporter callfor keep-alive servers, since theDaemonClientauto-launches the daemon in the background.Fix
Detect the
/$bunfs/prefix inresolveCliEntry()and omit it from spawn args — Bun already injects it automatically in the child.Testing
pnpm test— all 418 tests passbun run scripts/build-bun.tsthendaemon start/status/stopcycle worksnode dist/cli.js daemon startstill works (no regression)Fixes #78